@using System.Text
@using BlazorDatasheet.Util
@implements IHandleEvent

<!-- The cell content -->

@if (true)
{
    <div
        class="cell"
        style="@CellFormatStyleString">
        @if (Icon != null)
        {
            <div style="margin-right:2px; float:left; color: @(IconColor ?? "var(--icon-color)");">@Icon</div>
        }
        @ItemTemplate
    </div>
}

@code {


    [Parameter, EditorRequired]
    public string CellFormatStyleString { get; set; } = string.Empty;

    [Parameter, EditorRequired]
    public RenderFragment ItemTemplate { get; set; }

    [Parameter, EditorRequired]
    public bool IsDirty { get; set; }

    [Parameter]
    public RenderFragment? Icon { get; set; }

    [Parameter]
    public string IconColor { get; set; } = "black";


    protected override bool ShouldRender()
    {
        return IsDirty;
    }

    protected override void OnAfterRender(bool firstRender)
    {
        base.OnAfterRender(firstRender);
    }

    Task IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, object? arg) => callback.InvokeAsync(arg);

}